package cn.woniu.ecommerceplatform.controller;

import cn.woniu.ecommerceplatform.entity.Orders;
import cn.woniu.ecommerceplatform.service.GoodsService;
import cn.woniu.ecommerceplatform.service.OrdersService;
import cn.woniu.ecommerceplatform.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/orders")
public class OrderController {

    @Autowired
    private OrdersService ordersService;

    @RequestMapping("orderList")
    public ResponseResult<?> orderList(String goodName, String orderNum, Integer orderState, String account, Integer pageNum, Integer pageSize){
        return ordersService.orderList(goodName, orderNum, orderState, account, pageNum, pageSize);
    }

    @PostMapping("orderAdd")
    public ResponseResult<?> orderAdd(@RequestBody Orders orders){
        return ordersService.orderAdd(orders);
    }
    @RequestMapping("/addByGood")
    public ResponseResult<?> orderByGoodAdd(  Integer id,Integer num, String account){
        return ordersService.orderByGoodAdd(id,num,account);
    }

    @RequestMapping("orderDelete")
    public ResponseResult<?> orderDelete(Orders orders){
        return ordersService.orderDelete(orders);
    }

    @PostMapping("batchDelete")
    public ResponseResult<?> batchDelete(@RequestBody List<Integer> ids,String account){
        return  ordersService.batchDelete(ids,account);
    }

    @PostMapping("orderUpdate")
    public ResponseResult<?> orderUpdate(@RequestBody Orders orders){
        return ordersService.orderUpdate(orders);
    }

    @RequestMapping("orderDetails")
    public ResponseResult<?> orderDetails(Integer orderId){
        return ordersService.orderDetails(orderId);
    }

    @PostMapping("orderDetailsAdd")
    public ResponseResult<?> orderDetailsAdd(@RequestBody Orders orders){
        return ordersService.orderDetailsAdd(orders);
    }

    @PostMapping("orderUpdateOrderState")
    public ResponseResult<?> orderUpdateOrderState(@RequestBody Orders orders){
        return ordersService.orderUpdateOrderState(orders);
    }

    @PostMapping("orderUpdateComments")
    public ResponseResult<?> orderUpdateComments(@RequestBody Orders orders){
        return ordersService.orderUpdateComments(orders);
    }
}
